#!/bin/bash

project=$1
arch=$2
pkglist=`osc list $project`
#project="openEuler:Mainline"
#pkglist=`osc list $project`
#pkglist=`cat ./pkglist`
> ./all_result_${arch}.log

for pkg in $pkglist
do
	osc remotebuildlog $project $pkg standard_$arch $arch 2>/dev/null > ./${arch}_pkg_logfile
	if [ -s ${arch}_pkg_logfile ];then
		str=`sed -nr '/querying package ids+/{n;p}' ${arch}_pkg_logfile`
		str=`echo ${str#*/}`
		str=`echo ${str%]*}`
		echo "$pkg     $str">> ./all_result_${arch}.log
	else
		echo "$pkg     null">> ./all_result_${arch}.log
	fi
done
